#
#
CLEANFILES = ctoolparser_dbg.y ctoolparser_nodbg.y \
	ctoolscan_dbg.l ctoolscan_nodbg.l \
	*~
DISTCLEANFILES = *~

CONDPP = ../../buildtool/condpp.sh

bin_PROGRAMS = ebctool

SOURCES_common = ebctool.c ebctool.h ebctool_help.c

if ECM_PARSER

BUILT_SOURCES = ctoolparser_dbg.y ctoolparser_nodbg.y \
	ctoolscan_dbg.l ctoolscan_nodbg.l \
	ctoolparser_dbg.c ctoolparser_nodbg.c \
	ctoolscan_dbg.c ctoolscan_nodbg.c

ctoolparser_dbg.y: ctoolparser.y
	$(CONDPP) -d $< > ctoolparser_dbg.y

ctoolparser_nodbg.y: ctoolparser.y
	$(CONDPP) $< > ctoolparser_nodbg.y

ctoolscan_dbg.l: ctoolscan.l
	$(CONDPP) -d $< > ctoolscan_dbg.l

ctoolscan_nodbg.l: ctoolscan.l
	$(CONDPP) $< > ctoolscan_nodbg.l

ctoolscan_dbg.c: ctoolscan_dbg.l
	flex $(AM_LFLAGS) -d -o$@ $<

ctoolscan_nodbg.c: ctoolscan_nodbg.l
	flex $(AM_LFLAGS) -o$@ $<

if ECM_DEBUG

PARSER_SOURCES = ctoolparser_dbg.y
SCANNER_SOURCES = ctoolscan_dbg.c

else

PARSER_SOURCES = ctoolparser_nodbg.y
SCANNER_SOURCES = ctoolscan_nodbg.c

endif

else

if ECM_DEBUG

PARSER_SOURCES = ctoolparser_dbg.c
SCANNER_SOURCES = ctoolscan_dbg.c

else

PARSER_SOURCES = ctoolparser_nodbg.c
SCANNER_SOURCES = ctoolscan_nodbg.c

endif

endif

ebctool_SOURCES = $(SOURCES_common) $(PARSER_SOURCES) $(SCANNER_SOURCES)

INCLUDES = -I../../lib/libbase -I../../lib/libsr -I../../lib/libebc

AM_YFLAGS = -d -p ct -t
AM_LFLAGS = -Pct --nounistd

ebctool_LDADD = ../../lib/libebc/libebc.la ../../lib/libsr/libsr.la ../../lib/libbase/libbase.la -lreadline -lhistory -lcurses -lm @LINK_DL@ -lpthread

EXTRA_DIST = ctoolparser.y ctoolparser_dbg.y ctoolparser_nodbg.y ctoolscan_dbg.c ctoolscan_nodbg.c ctoolscan.l
